package com.example.physicalexaminationsystem.controller;

import com.example.physicalexaminationsystem.dto.ResponseDto;
import com.example.physicalexaminationsystem.service.RegistrationService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author shiwenzhuo
 * 
 * @description
 */
@RestController
@RequestMapping("/api/registration")
public class RegistrationManagementController {
    @Resource
    RegistrationService registrationService;

    //预约体检接口
    @RequestMapping("/appointment")
    public ResponseDto Appointment(@RequestBody Map<String, Object> params) {
        return registrationService.appointment(params);
    }

    //取消预约接口
    @RequestMapping("/cancelAppointment")
    public ResponseDto cancelAppointment(@RequestParam("name") String name) {
        registrationService.cancelAppointment(name);
        return ResponseDto.success();
    }

    //查询预约信息接口
    @RequestMapping("/getAppointmentInfo")
    public ResponseDto getAppointmentInfo(@RequestParam("name") String name) {
        return ResponseDto.success(registrationService.getAppointmentInfo(name));
    }

    //获取体检费用信息
    @RequestMapping("/getExaminationFee")
    public ResponseDto getExaminationFee(@RequestParam("name") String name) {
        return ResponseDto.success(registrationService.getExaminationFee(name));
    }

    //体检付费
    @RequestMapping("/payExaminationFee")
    public ResponseDto payExaminationFee(@RequestParam("name") String name) {
        return registrationService.pay(name) ? ResponseDto.success() : ResponseDto.fail("付费失败");
    }
}
